package Service;

import java.util.ArrayList;

import vo.Status;
import dao.StatusDao;

public class StatusService {

	/**
	 * @author 韩 闻文 total number of statuses
	 * @return
	 */
	public static int getCount() {
		return StatusDao.getCountByCondition(null);
	}

	/**
	 * @author 韩 闻文
	 * @param startTime
	 *            , endTime total comments
	 * @return
	 */
	public static int getCountByTimeRange(String startTime, String endTime) {
		Status status = new Status();
		status.setStartTime(startTime);
		status.setEndTime(endTime);
		return StatusDao.getCountByCondition(status);
	}

	/**
	 * @author 韩 闻文 get status count by source type
	 * @return
	 */
	public static int getCountBySourceName(String sourceName) {
		Status status = new Status();
		status.setSourceName(sourceName);
		return StatusDao.getCountByCondition(status);
	}

	public static int getCountByUserId(String userId) {
		Status status = new Status();
		status.setUserId(userId);
		return StatusDao.getCountByCondition(status);
	}

	/**
	 * @author 韩 闻文 get count of all statues belonged to the same user
	 * @param userId
	 * @return
	 */
	public static int getCountByTimeRangeUserId(String startTime, String endTime, String userId) {
		Status status = new Status();
		status.setUserId(userId);
		status.setStartTime(startTime);
		status.setEndTime(endTime);
		return StatusDao.getCountByCondition(status);
	}

	/**
	 * @author 韩 闻文 get all statues belonged to the same user
	 * @param userId
	 * @return
	 */
	public static ArrayList<Status> getByUserId(String userId) {
		Status status = new Status();
		status.setUserId(userId);
		ArrayList<Status> result = StatusDao.getByCondition(status);
		return result;
	}

	public static ArrayList<Status> getStatusesByUserId(String userId) {
		Status status = new Status();
		status.setUserId(userId);
		return StatusDao.getByCondition(status);

	}

	public static void main(String args[]) {
	}

}
